import information from './../../api/information.js'

const informat = {
  state:{
    name: '',
    no:'',
    sex:'',
    college:'',
    class:'',
    identity:'',
    state:'',
    department:'',
    campus:'',
    phone:'',
    email:'',
    qq:'',
    bank:'',
    introduction:'',
    allDepartment:'',
    allCampus:''
  },
  getters:{

  },
  actions:{

  },
  mutations:{
    setInformation(state){
      if(state.no==''){
        information.information()
        .then(data=>{
          state.name=data.result.realName;
          state.no=data.result.studentNumber;
          state.sex=data.result.sex;
          state.college=data.result.college;
          state.class=data.result.major;
          state.identity=data.result.positionName;
          state.state=data.result.state;
          state.campus=data.result.campus;
          state.phone=data.result.phone;
          state.email=data.result.email;
          state.qq=data.result.qq;
          state.bank=data.result.debitCard;
          state.introduction=data.result.introduction;
          state.department=data.result.department
        })
        .catch(err => {
          console.log(err)
        })
      }
    },
    setCampus(state){
      if (state.allCampus=='') {
        information.campus()
        .then(data=>{
          state.allCampus=data.result
          console.log(state.allCampus)
        })
        .catch(err => {
        // this.$Message.error(err);
        console.log(err)
      })
      }
    },
    setDepartment(state){
      if (state.allDepartment=='') {
        information.department()
        .then(data=>{
          state.allDepartment=data.result
          console.log(state.allDepartment)
        })
        .catch(err => {
        // this.$Message.error(err);
        console.log(err)
      })
      }
    }
  }
};
export default informat
